package net.lcheng.commons.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by qiliping on 15/12/19.
 */
public class DateFormatHelper {
    public static Date StringToDate(String dateString){
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            Date date = sdf.parse(dateString);
            return date;
        }
        catch (ParseException e) {
            return null;
        }

    }



    public static String DateToFormatString(Date date){
        if (date!=null){
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            return sdf.format(date);
        }return null;
    }
}
